//两数之和
let nums = [2,7,11,15];
let target = 9;
const twoSum = ()=>{
    let obj = {};
    for(let i=0;i<nums.length;i++){
        if(obj[target-nums[i]] !== undefined){
            return [obj[target-nums[i]],i]
        }
        obj[nums[i]] = i
    }
}
console.log(twoSum(nums,target));

//解决了，两数之和也是蛮简单的题目。